
function selectPermission(){
	
	var url = '/storage/admin/pages/operator.do?method=selectPermission&d=' + new Date();
	
	$.getJSON(url, {}, function(data){
		var permission_list_val = '';
		for(var i=0;i<data.length;i++){
			permission_list_val = permission_list_val + '<input type="checkbox" name="oper_perm" value="'+data[i][0]+'" />'+data[i][1]+'<br />'; 
		}
		$('#permission_list').html(permission_list_val);
	});

};
function selectOperatorInfo(emp_id,emp_name,opr_name){

	$('#emp_id').val(emp_id);
	$('#emp_name').html(emp_name);
	$('#opr_name').html(opr_name);
	
	var url = '/storage/admin/pages/operator.do?method=selectOperatorInfo&d=' + new Date();
	url = url + '&emp_id='+emp_id;

	$.getJSON(url, {}, function(data){
		var perms = document.getElementsByName('oper_perm');
		for(var i=0;i<data.length;i++){
			for(var m=0;m<perms.length;m++){
				if(perms[m].value==data[i][0]){
					perms[m].checked=true;
					break;
				}
			}
		}
	});
};
function updateOperPerm(){
	var sn = 0;
	var emp_id = $('#emp_id').val();
	var oper_perm = new Array();
	var perms = document.getElementsByName('oper_perm');
	for(var m=0;m<perms.length;m++){
		if(perms[m].checked){
			oper_perm[sn] = perms[m].value;
			sn++;
		}
	}
	
	var url = '/storage/admin/pages/operator.do?method=updateOperPerm&d=' + new Date();
	url = url + '&emp_id='+emp_id;
	url = url + '&oper_perm='+oper_perm;
	
	$.getJSON(url, {}, function(data){
		if(data=="true"){
			alert("修改成功");
			window.close();
		}else{
			alert("修改失败");
		}
	});
};
